<!-- 本示例未包含完整css，获取外链css请参考上文，在hello uni-app项目中查看 -->
<template>
	<view>
		<view>
			<form @submit="formSubmit" @reset="formReset">
				<view class="uni-form-item uni-column">
					<view class="title">switch</view>
					<view>
						<switch name="switch" />
					</view>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">radio</view>
					<radio-group name="radio">
						<label>
							<radio value="radio1" /><text>选项一</text>
						</label>
						<label>
							<radio value="radio2" /><text>选项二</text>
						</label>
					</radio-group>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">checkbox</view>
					<checkbox-group name="checkbox">
						<label>
							<checkbox value="checkbox1" /><text>选项一</text>
						</label>
						<label>
							<checkbox value="checkbox2" /><text>选项二</text>
						</label>
					</checkbox-group>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">slider</view>
					<slider value="50" name="slider" show-value></slider>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">input</view>
					<input class="uni-input" name="input" placeholder="这是一个输入框" />
				</view>
				<view class="uni-btn-v">
					<button form-type="submit">Submit</button>
					<button type="default" form-type="reset">Reset</button>
				</view>
			</form>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
			}
		},
		methods: {
			formSubmit: function(e) {
				console.log('form发生了submit事件，携带数据为：' + JSON.stringify(e.detail.value))
				var formdata = e.detail.value
				uni.showModal({
					content: '表单数据内容：' + JSON.stringify(formdata),
					showCancel: false
				});
			},
			formReset: function(e) {
				console.log('清空数据')
			}
		}
	}
</script>


<style lang="scss" scoped>
/* ========== 基础变量 ========== */
page {
  --uni-primary: #2979ff;
  --uni-text: #333;
  --uni-text-light: #666;
  --uni-border: #e5e5e5;
  --uni-bg: #f8f8f8;
}

/* ========== 统一间距 ========== */
.uni-common-mt {
  margin-top: 30rpx;
}
.uni-form-item {
  margin: 0 30rpx 40rpx;
  background: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.uni-form-item .title {
  font-size: 32rpx;
  font-weight: 600;
  color: var(--uni-primary);
  margin-bottom: 20rpx;
}

/* ========== 列表单元格 ========== */
.uni-list {
  display: flex;
  flex-direction: column;
}
.uni-list-cell {
  display: flex;
  align-items: center;
  padding: 24rpx 0;
  border-bottom: 2rpx solid var(--uni-border);
}
.uni-list-cell:last-child {
  border-bottom: none;
}
.uni-list-cell-pd {
  padding-left: 20rpx;
  padding-right: 20rpx;
}

/* ========== checkbox / radio 对齐 ========== */
checkbox,
radio {
  margin-right: 16rpx;
  transform: scale(0.8); /* 统一尺寸 */
}

/* ========== label-2-text（for 写法） ========== */
.label-2-text {
  font-size: 30rpx;
  color: var(--uni-text);
}

/* ========== label-3 多选区域 ========== */
.label-3 {
  display: flex;
  flex-direction: column;
}
.checkbox-3 {
  font-size: 30rpx;
  color: var(--uni-text);
}

/* ========== 提示文字 ========== */
.uni-link {
  font-size: 28rpx;
  color: var(--uni-primary);
}
.uni-center {
  text-align: center;
}
</style>
